<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    :root {
      --left-bg-color: rgba(87, 84, 236, 0.7);
      --right-bg-color: rgba(43, 43, 43, 0.8);
      --left-btn-hover-color: rgba(87, 84, 236, 1);
      --right-btn-hover-color: rgba(28, 122, 28, 1);
      --hover-width: 75%;
      --other-width: 25%;
      --speed: 1000ms;
    }
    * {
      box-sizing: border-box;
    }
    html {
      font-size: 15px;
    }
    body {
      font-family: 'Roboto', sans-serif;
      height: 100vh;
      overflow: hidden;
      margin: 0;
    }
    .container {
      position: relative;
      width: 100%;
      height: 100%;
      background-color: #333;
    }
    .split {
      position: absolute;
      width: 50%;
      height: 100vh;
      overflow: hidden;
    }
    .split.left {
      left: 0;
      background: url(./images/ps5.jpg);
      background-repeat: no-repeat;
      background-size: cover;
    }
    .split.right {
      right: 0;
      background: url(./images/xbox.jpg);
      background-repeat: no-repeat;
      background-size: cover;
    }
    .split h1 {
      font-size: 4rem;
      color: #fff;
      position: absolute;
      top: 20%;
      left: 50%;
      transform: translateX(-50%);
      white-space: nowrap;
    }
    .split .btn {
      display: flex;
      justify-content: center;
      position: absolute;
      top: 40%;
      left: 50%;
      transform: translateX(-50%);
      width: 15rem;
      text-decoration: none;
      padding: 1.5rem;
      color: #fff;
      border: solid #fff 0.2rem;
      font-weight: bold;
    }
    .split.left .btn:hover {
      background-color: var(--left-btn-hover-color);
      border-color: var(--left-btn-hover-color);
    }
    .split.right .btn:hover {
      background-color: var(--right-btn-hover-color);
      border-color: var(--right-btn-hover-color);
    }
    .split.left::before {
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: var(--left-bg-color)
    }
    .split.right::before {
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: var(--right-bg-color)
    }
    .split.right,
    .split.left,
    .split.right::before,
    .split.left::before {
      transition: all var(--speed) ease-in-out;
    }
    /* hover-left是加在contanier里面的 */
    .hover-left .left{
      width: var(--hover-width);
    }
    .hover-left .right {
      width: var(--other-width);
    }
    .hover-right .left{
      width: var(--other-width);
    }
    .hover-right .right {
      width: var(--hover-width);
    }
    @media (max-width: 800px) {
      h1 {
        font-size: 2rem;
        top: 30%;
      }
      btn {
        padding: 1.2rem;
        width: 12rem;
      }
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="split left">
      <h1>Playstation 5</h1>
      <a href="#" class="btn">Buy Now</a>
    </div>
    <div class="split right">
      <h1>XBox Series X</h1>
      <a href="#" class="btn">Buy Now</a>
    </div>
  </div>

  <script>
    const container = document.querySelector(".container");
    const left = document.querySelector(".left");
    const right = document.querySelector(".right");

    left.addEventListener("mouseenter", () => {container.classList.add("hover-left")});
    left.addEventListener("mouseleave", () => {container.classList.remove("hover-left")});

    right.addEventListener("mouseenter", () => {container.classList.add("hover-right")});
    right.addEventListener("mouseleave", () => {container.classList.remove("hover-right")});
  </script>
</body>
</html>